package de.duester.vectordrawing.object;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.graphics.RectF;

/**
 * @author Maxim Duester
 */
public class Ellipse extends Arc {

	/**
	 * 
	 */
	public Ellipse() {
	}

	/**
	 * @param p
	 * @param width
	 * @param height
	 */
	public Ellipse(PointF p, float width, float height) {
		super(p, width, height, 0, 360);
		setColors(Color.BLACK, Color.WHITE);
	}

	/* (non-Javadoc)
	 * @see de.duester.vectordrawing.object.Arc#getNonRotatedImage()
	 */
	@Override
	protected Bitmap getNonRotatedImage() {
		paint.setStyle(Style.FILL);
		paint.setColor(getColor(1));

		PointF p = getScaledAndTransformedRelative(new PointF(getWidth(), getHeight()));
		float w = p.x;
		float h = p.y;
		RectF r = new RectF(0, 0, w, h);

		Bitmap b = Bitmap.createBitmap((int) w, (int) h, Config.ARGB_8888);
		Canvas canvas = new Canvas(b);
		canvas.drawOval(r, paint);

		paint.setStyle(Style.STROKE);
		paint.setColor(getColor(0));

		canvas.drawOval(r, paint);
		return b;
	}
}
